<?php

class Application_Model_UserStatuses
{
    /**
     * Returns an array with valid user statuses
     *
     * @return array
     */
    static function getValidStatuses()
    {
        // NOTE: to add status you need to modify database table
        return array(
            0,   //  first one is default (not active)
            1,   //  second one is active
            2   //   last one is blocked
        );
    }

    /**
     * Returns default status ID
     *
     * @return int
     */
    static function getDefaultStatus()
    {
        $statuses=self::getValidStatuses();
        
        return $statuses[0];
    }
    
    /**
     * Returns active status ID
     *
     * @return int
     */
    static function getActiveStatus()
    {
        $statuses=self::getValidStatuses();
        
        return $statuses[1];
    }
    
    /**
     * Returns blocked status ID
     *
     * @return int
     */
    static function getBlockedStatus()
    {
        $statuses=self::getValidStatuses();
        
        return $statuses[count($statuses)-1];
    }
    
    /**
     * Checks if given status is valid
     *
     * @param int $status
     * @return bool
     */
    static function isValidStatus($status)
    {
        $valid=self::getValidStatuses();
        
        return in_array($status,$valid) ? true : false;
    }
    
    /**
     * Returns status' human name
     *
     * @param string $status
     * @return string
     */
    static function getStatusName($status)
    {
        return Zend_Registry::get('locale')->_('status:'.$status);
    }
    
    /**
     * Returns an associative array with status names
     *
     * @return array
     */
    static function getStatuses()
    {
        $statuses=array();
        
        $valid=self::getValidStatuses();
        
        foreach ($valid as $status)
        {
            $statuses[$status]=self::getStatusName($status);
        }
        
        return $statuses;
    }
}

